<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>角色列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="<%=path%>/css/pintuer.css">
<link rel="stylesheet" href="<%=path%>/css/admin.css">
<link rel="shortcut icon" href="<%=path%>/images/login.jfif">
<script src="<%=path%>/js/jquery.js"></script>
</head>
<body>
	<form method="post" action="<%=path%>/role/role_list" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder"> 角色信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li><a class="button border-main icon-plus-square-o"
						href=<c:url value='http://127.0.0.1:8080/mxbbx_lzs/role/role_add'/>>
							添加角色</a></li>
					<li>搜索：</li>
					<li><input type="text" placeholder="请输入搜索关键字" name="keyword"
						id="keyword" class="input"
						style="width:250px; line-height:17px;display:inline-block" /> <input
						type="submit" name="chaxun" value="查询"
						class="button border-main icon-search" /></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th width="90" style="text-align:center;">&nbsp;</th>
					<th>角色编号</th>
					<th>角色名称</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${page.list}" var="item" varStatus="status">
					<tr>
						<td><input type="checkbox" name="ids" value="${item.id}" /></td>
						<td id="roleid_td">${item.roleid}</td>
						<td id="rolename_td">${item.rolename}</td>
						<td><div class="button-group">
								<a class="button border-main"
									href="<c:url value='http://127.0.0.1:8080/mxbbx_lzs/role/role_update?roleid=${item.roleid}'/>"><span
									class="icon-edit"></span> 修改</a> <a class="button border-red delete_btn"  href=""
                                     id="delete"  onclick="deleteRole(${item.roleid})"><span class="icon-trash-o"></span> 删除</a>
							</div></td>
					</tr>
				</c:forEach>
			</table>
			<div class="pagelist">

				<div>共有${page.totalRecord}条记录，共${page.totalPage }页，当前为第${page.pageNum}页</div>
				<br /> <a
					href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=1">首页</a>
				<%--如果当前页为第一页时，就没有上一页这个超链接显示 --%>
				<c:if test="${page.pageNum ==1}">
					<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
						<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
						<c:if test="${page.pageNum != i}">
							<a
								href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${i}">${i}</a>
						</c:if>
					</c:forEach>
					<a
						href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${page.pageNum+1}">下一页</a>
				</c:if>

				<%--如果当前页不是第一页也不是最后一页，则有上一页和下一页这个超链接显示 --%>

				<c:if test="${page.pageNum > 1 && page.pageNum < page.totalPage}">
					<a
						href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${page.pageNum-1}">上一页</a>
					<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
						<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
						<c:if test="${page.pageNum != i}">
							<a
								href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${i}">${i}</a>
						</c:if>
					</c:forEach>
					<a
						href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${page.pageNum+1}">下一页</a>
				</c:if>

				<%-- 如果当前页是最后一页，则只有上一页这个超链接显示，下一页没有 --%>
				<c:if test="${page.pageNum == page.totalPage && page.pageNum!=1}">
					<a
						href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${page.pageNum-1}">上一页</a>
					<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
						<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
						<c:if test="${page.pageNum != i}">
							<a
								href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${i}">${i}</a>
						</c:if>
					</c:forEach>
				</c:if>
				<%--尾页 --%>
				<a
					href="http://127.0.0.1:8080/mxbbx_lzs/role/role_list?pageNum=${page.totalPage}">尾页</a>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript">
// $(document).on("click",".delete_btn",function(){
// var roleid1 =$("#roleid_td").text();
// var roleid = $(this).parents().find("tr").find("td:eq(1)").text();
// alert(roleid);
// alert(roleid1);
// //  $.ajax({
// //      typr:"POST",
 <%--      url:"<%=path%>/role/role_delete",  --%> 
// //      data:"roleid="+roleid,
// //      success:(function(result){
// //     console.log(result)
// //         })
// //       })
//  });

function deleteRole(roleid){

 $.ajax({
     url:"<%=path%>/role/role_delete", 
     data:{roleid:roleid},
     success:function(result){
      alert("删除成功")
     }

 })
}

</script>
</html>
